package com.tz.actions;

import com.opensymphony.xwork2.ActionSupport;
import com.tz.dao.AddressDao;
import com.tz.dao.UserDao;
import com.tz.entity.Address;
import com.tz.entity.User;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 用户管理
 */
public class UserAction extends ActionSupport {

    private static final long serialVersionUID = -489087216774349455L;

    @Autowired
    private UserDao userDao;

    @Autowired
    private AddressDao addressDao;

    private User user;
    private Address address;

    private boolean result;

    public String register() {
        userDao.save(user);
        address.setUser(user);
        addressDao.save(address);
        return SUCCESS;
    }

    public User getUser() {
        return user;
    }


    public void setUser(User user) {
        this.user = user;
    }


    public Address getAddress() {
        return address;
    }


    public void setAddress(Address address) {
        this.address = address;
    }


    public boolean isResult() {
        return result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

}
